﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

namespace MaluJg.web.Stats
{
    public partial class yearselect2 : System.Web.UI.UserControl
    {
        protected int Year
        {
            get
            {
                int _year = 0;
                int.TryParse(Request["year"] ?? "0", out _year);
                if (_year == 0)
                    _year = DateTime.Today.Year;
                return _year;
            }

        }

        public bool IsShow
        {
            get
            {
                if (ViewState["IsShow"] == null)
                    return false;
                else
                    return (bool)ViewState["IsShow"];
            }
            set {
                ViewState["IsShow"] = value;
            }
        }
        protected string StrShow = string.Empty;
        protected string StrNoShow = string.Empty;
        protected void Page_Load(object sender, EventArgs e)
        {
            StrShow = IsShow ? "none" : "";
            StrNoShow = (!IsShow) ? "none" : "";
            if (!IsPostBack)
            {
              

                DataTable dt = new DataTable();
                dt.Columns.Add("year");
                dt.Columns.Add("className");

                for (int i = 2010; i <= DateTime.Today.Year; i++)
                {
                    DataRow dr = dt.NewRow();
                    dr["year"] = i.ToString();
                    dr["className"] = "classred";
                    if (i == Year)
                    {
                        dr["className"] = "classredcur";
                    }
                    dt.Rows.Add(dr);
                }
                rpYear.DataSource = dt;
                rpYear.DataBind();
            }
        }
    }
}